<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Sudoku</title>

</head><body>
<center style="color: rgb(0, 153, 0);">
<h1 style="font-family: Helvetica,Arial,sans-serif;">Project
Description<br>
SuDoKu
</h1>
</center>
<h2 style="color: rgb(0, 153, 0);"><span style="font-family: Helvetica,Arial,sans-serif;">Overview</span></h2>
<p>For this project you will complete a skeleton C program that
presents a sudoku puzzle to a player and provides commands for the
player to incrementally solve the puzzle. <a href="http://www.sudokuessentials.com/sudoku_rules.html">Here
is a tutorial on the rules of sudoku</a> for those who are
unfamiliar with the game.</p>
<h2 style="color: rgb(0, 153, 0);"><span style="font-family: Helvetica,Arial,sans-serif;">Setup</span></h2>
<p><a href="./sudoku.zip">Download the file
sudoku.zip</a> from the software engineering web to a clean
working directory for this project. Unzip the file - on linus you can
use the command:</p>
<p style="margin-left: 40px;"><span style="font-family: Lucida Console; font-weight: bold;">unzip
sudoku.zip</span></p>
<p>which will place all the files in the zip archive in the
current directory. At this point you can remove sudoku.zip; should you
need it later (e.g., for disaster recovery) you can always download it
from this page. At this point you should see the following files
&amp; directories:</p>
<dl>
<dt style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">bool.h</dt>
<dd>A&nbsp;header file declaring a pseudo-type for <span style="font-family: Lucida Console; font-weight: bold;">bool</span>
along with constants <span style="font-family: Lucida Console; font-weight: bold;">FALSE</span>
and <span style="font-family: Lucida Console; font-weight: bold;">TRUE</span>.</dd>
<dt style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">main.c</dt>
<dd>
The main driver function: It parses the command line arguments,
initializes the puzzle, loads the puzzle configuration from a file
provided as an argument, and, if the load succeeds, reads user commands
(one command per input line) and calls the appropriate processing
function in the <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle</span>
module.
</dd>
<dt style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">arguments.h &amp;
arguments.c</dt>
<dd>Interface to and implementation of a module processing the
command line arguments to (a) determine whether or not the input
commands should be echoed (optional <span style="font-weight: bold; color: rgb(51, 51, 255);">-e</span>
flag), and (b) open the puzzle configuration file, which defines the
initial state of the puzzle. Exits with appropriate messages if there
are problems with the arguments provided.<br>
<span style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">Note:</span>
You need not concern yourself with this module, as it is only used by
the main function. On the other hand, perusing it would give you
&nbsp;examples of using some standard C functions and idioms.</dd>
<dt style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">puzzle.h &amp;
puzzle.c</dt>
<dd>The <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle</span>
module you will complete. The header, <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle.h</span>,
defines the interface you <span style="font-weight: bold; font-style: italic; text-decoration: underline; color: rgb(204, 0, 0);">must</span>
adhere to, as the only source file you will submit is the corresponding
implementation, <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle.c</span>.
In particular, <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle.c</span>
is the <span style="font-style: italic;">one file you
must edit</span> and the <span style="font-style: italic;">only
file you may edit</span>.</dd>
<dt style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">solve_sudoku &amp;
skeleton_sudoku</dt>
<dd>Two executable files, compiled and linked for Linux. <span style="font-weight: bold; color: rgb(51, 51, 255);">solve_sudoku</span>
represents a full, complete implementation of the requirements,
including error handling; use it as a reference against which to
compare your program as you go along. <span style="font-weight: bold; color: rgb(51, 51, 255);">skeleton_sudoku</span>
was compiled directly from the files we provide;&nbsp;all the
functions in the <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle.c</span>
file have been stubbed out, and those functions with return values
return whatever is required to make it appear that everything proceeds
normally. This can be used as a baseline for comparison with your
version.</dd>
<dt style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">Makefile</dt>
<dd>A file making it easy to compile the source code and link
the object files. To create an executable file named <span style="font-weight: bold; color: rgb(51, 51, 255);">sudoku</span> use the command:<br><br><span style="font-family: Lucida Console;">&nbsp; &nbsp; <span style="font-weight: bold;">make sudoku</span></span><br><br>As you add functionality to the <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle.c</span>
implementation, this executable will be used to test your changes. <span style="font-weight: bold; color: rgb(51, 51, 255);">Makefile</span>
also has a series of targets to run your program using different valid
and erroneous puzzle configurations, as well as command scripts that
are error free or seeded with specific types of errors. More on these
tests below.</dd>
<dt style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">p+s</dt>
<dd>A directory with (<span style="font-weight: bold; color: rgb(51, 51, 255);">p</span>)uzzle
configurations and command (<span style="font-weight: bold; color: rgb(51, 51, 255);">s</span>)cripts
for use in testing.</dd><dt style="font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Description.html</dt><dd>This file (in case you are working remotely and can't access the SE web servers).</dd><dt style="font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Process_Reflection.doc</dt><dd>An
M/S Word file in which you record your estimate and actual time it took
to do each level, along with reflections on why they diverge (if they
do) and your perception of the project as a whole.</dd>
</dl>
<p><span style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">Note:</span>
If you have problems running either <span style="font-weight: bold; color: rgb(51, 51, 255);">solve_sudoku</span>
or <span style="font-weight: bold; color: rgb(51, 51, 255);">skeleton_sudoku</span>,
this is probably because the files are exectuable. To fix this, run the
following command on Linus:</p>
<div style="margin-left: 40px;"><span style="font-family: Lucida Console; font-weight: bold;">chmod
+x solve_sudoku skeleton_sudoku</span></div>
<p>This will set the e(<span style="font-weight: bold; color: rgb(51, 51, 255);">x</span>)ecute
permission on these files, at which point you should be able to run
them.<br>
</p>
<h2 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 153, 0);">Using
the Example Programs</h2>
<p>All the examples will be given using <span style="font-weight: bold; color: rgb(51, 51, 255);">solve_sudoku</span>.
You can substitute <span style="font-weight: bold; color: rgb(51, 51, 255);">skeleton_sudoku</span>,
but the program will look like it did nothing (which, in fact, is what
happens in the skeleton). And, of course, as you implement the required
functionality, you can use your compiled version, <span style="font-weight: bold; color: rgb(51, 51, 255);">sudoku</span>.</p>
<p>The program is invoked in one of two ways:</p>
<p style="margin-left: 40px; font-family: Lucida Console; font-weight: bold;">./solve_sudoku
configfile<br>
./solve_sudoku -e configfile</p>
<p>In both cases,&nbsp;<span style="font-weight: bold; color: rgb(51, 51, 255);">configfile</span>
is a text file giving the initial placement of digits in the puzzle.
The optional <span style="font-weight: bold; color: rgb(51, 51, 255);">-e</span>
flag determines whether or not the user commands are echoed to standard
output. If you're running on the console and typing in commands, you
should probably not use the flag. On the other hand, if you are running
commands from a script (a text file), then <span style="font-weight: bold; color: rgb(51, 51, 255);">-e</span>
lets you see what commands are executed in sequence.</p>
<p style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">Example</p>
<p style="margin-left: 40px; font-family: Lucida Console; font-weight: bold;">./solve_sudoku
-e p+s/good_puzzle.txt &lt; p+s/script_good_solve_puzzle.txt</p>
runs the program using a legitimate puzzle configuration in <span style="font-weight: bold; color: rgb(51, 51, 255);">p+s/good_puzzle.txt</span>
with echoing turned on and the commands coming from the script file <span style="font-weight: bold; color: rgb(51, 51, 255);">p+s/script_good_solve_puzzle.txt</span>
- this script has&nbsp;commands that add digits to the puzzle to
solve it. Along the way, the partial puzzle solution is printed at
several points.
<p>You could run the puzzle interactively as follows:</p>
<p style="margin-left: 40px; font-family: Lucida Console; font-weight: bold;">./solve_sudoku&nbsp;p+s/good_puzzle.txt</p>
<p>In this case, the main program directs the initialization and
loading of the puzzle configuration, prints the initial board, and
enters the command loop. Each time through the loop the program prompts
command: to which you respond with a single lower-case letter command
and possibly digits used by the command. Spacing is important: the
command letter must be the first character on the line, and the command
and arguments are separated from each other by a single digit; each
command is terminated by a newline. The commands are:</p>
<table style="margin-left: 40px;" border="1" cellpadding="3" cellspacing="1">
<tbody>
<tr>
<td style="font-family: Lucida Console; font-weight: bold;" valign="bottom">p</td>
<td valign="bottom">Print the puzzle</td>
</tr>
<tr>
<td style="font-family: Lucida Console; font-weight: bold;" valign="bottom">q</td>
<td valign="bottom">Quit (also on end-of-file)</td>
</tr>
<tr>
<td valign="bottom" width="80"><span style="font-family: Lucida Console; font-weight: bold;">a </span><span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">r</span><span style="font-family: Lucida Console; font-weight: bold;"> </span><span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">c</span><span style="font-family: Lucida Console; font-weight: bold;"> </span><span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">d</span></td>
<td valign="bottom">Add digit&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">d</span>
to the puzzle at row&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">r</span>
column <span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">c</span></td>
</tr>
<tr>
<td valign="bottom"><span style="font-family: Lucida Console; font-weight: bold;">e </span><span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">r</span><span style="font-family: Lucida Console; font-weight: bold;"> </span><span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">c</span><span style="font-family: Lucida Console; font-weight: bold;"> </span></td>
<td valign="bottom">Erase the digit at row&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">r</span>
column&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">c</span></td>
</tr>
</tbody>
</table>
<p>Rows, columns, and digits are all in the range&nbsp;<span style="font-weight: bold; font-family: Lucida Console;">1..9</span>.<br>
</p>
<h2 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 153, 0);">Design
Notes</h2>
<h3 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Puzzle
Configuration File Format</h3>
The configuration file comprises a series of 0 or more rows, each row
beginning with three digit characters giving the row, column, and value
for one of the initial placements in the puzzle. All three digits must
be in the range <span style="font-weight: bold; font-family: Lucida Console;">1..9</span>.
For example, the line <span style="font-family: Lucida Console; font-weight: bold;">135</span>
means&nbsp;<span style="font-family: Lucida Console; font-weight: bold;">5</span>
is to be placed at row&nbsp;<span style="font-family: Lucida Console; font-weight: bold;">1</span>,
column <span style="font-family: Lucida Console; font-weight: bold;">3</span>
in the initial configuration.<br>
<h3 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Puzzle
Data Structures</h3>
<p>The puzzle implementation is built on two 10x10 matrices: <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle</span>
and <span style="font-weight: bold; color: rgb(51, 51, 255);">fixed</span>.
The matrices are 10x10 to permit 1-based indexing into the 9x9 array
defining the puzzle proper; the 0th row and column are unused.</p>
<p>The <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle</span>
matrix holds the values placed so far, with 0 representing a blank
(available) location or cell. After initialization to all zeros, this
matrix is filled in first from the configuration file and then via
commands read from standing input. In later stages of the
implementation, the program will enforce the Sudoku consistency
constraints - a row, column, or 3x3 region may not contain the same
value in two cells.</p>
<p>The <span style="font-weight: bold; color: rgb(51, 51, 255);">fixed</span>
matrix is a boolean matrix initialized to all <span style="font-weight: bold; font-family: Lucida Console;">FALSE</span>
values. When a puzzle is configured (via data in a configuration file),
the row and column for each value so placed is set to <span style="font-weight: bold; font-family: Lucida Console;">TRUE</span>
in <span style="font-weight: bold; color: rgb(51, 51, 255);">fixed</span>.
In later stages of the implementation, attempting to erase a fixed
value is an error and the cell is not changed.</p>
<h3 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Puzzle
Module Interface</h3>
<p>The public interface has of an enumeration, <span style="font-weight: bold; color: rgb(51, 51, 255);">op_result</span>,
which is used to report back the status of each add or erase command. <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_OK</span>
signals success; the other values in the enumeration reflect the
different errors that may be detected. <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_BADARGS</span>
means the command gave a row, column, or digit that was not in the
range&nbsp;<span style="font-weight: bold; font-family: Lucida Console;">1..9</span>,
<span style="font-weight: bold; color: rgb(51, 51, 255);">OP_OCCUPIED</span>
is for attempts to place something at a location with an existing
value, <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_ILLEGAL</span>
is for placements that would violate the Sudoku rules (a duplicate
value in a row, column, or region), <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_EMPTY</span>
is for attempts to erase an empty cell, and <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_FIXED</span>
is for attempts to erase a fixed cell (one set by the puzzle
configuration). Only <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_OK</span>
results in a change to the puzzle layout; all erroneous commands have
no effect.</p>
<p>The interface proper is defined by five visible functions:<br>
</p>
<table style="margin-left: 30px; margin-right: 40px;" valign="top" border="1" cellpadding="3" cellspacing="1">
<tbody>
<tr>
<td style="font-weight: bold; font-family: Lucida Console;" valign="top">init_puzzle( )</td>
<td align="undefined" valign="top">Initialize
the <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle</span>
and <span style="font-weight: bold; color: rgb(51, 51, 255);">fixed</span>
matrices.</td>
</tr>
<tr>
<td style="font-weight: bold; font-family: Lucida Console;" valign="top">configure( <span style="font-family: Comic Sans MS; font-style: italic;">pf</span>
)</td>
<td align="undefined" valign="top">Read
configuration lines from the file whose handle is&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">pf</span>
and use this to fill out the <span style="font-weight: bold; color: rgb(51, 51, 255);">puzzle</span>
and <span style="font-weight: bold; color: rgb(51, 51, 255);">fixed</span>
matrices. If any configuration errors are encountered, this function
prints a message and exits - thus a return from this function
represents successful configuration.</td>
</tr>
<tr>
<td style="font-weight: bold; font-family: Lucida Console;" valign="top">print_puzzle( )</td>
<td align="undefined" valign="top">Print the
puzzle<br>
<div style="margin-left: 20px;">- The first line is
25 dashes (<span style="font-family: Lucida Console; font-weight: bold;"></span><span style="font-family: Lucida Console; font-weight: bold;">-</span><span style="font-family: Lucida Console; font-weight: bold;"></span>).<br>
- A line of 25 dashes is also printed after the 3rd, 6th, and 9th row
of the puzzle.<br>
- Each puzzle row begins with a vertical bar (<span style="font-family: Lucida Console; font-weight: bold;">|</span>)<br>
- Each cell in the row is printed as a space and the cell's value
(space
for a 0 value).<br>
- After the 3rd, 6th, and 9th colum, a space and a vertical bar are
printed.</div>
</td>
</tr>
<tr>
<td style="font-weight: bold; font-family: Lucida Console;" valign="top" width="225">add_digit(&nbsp;<span style="font-family: Comic Sans MS; font-style: italic;">r</span>,&nbsp;<span style="font-family: Comic Sans MS; font-style: italic;">c</span>,&nbsp;<span style="font-family: Comic Sans MS; font-style: italic;">d</span>
)</td>
<td align="undefined" valign="top">Add
digit&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">d</span>
to the puzzle cell at row&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">r</span>,
column&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">c</span>,
returning success or error status.</td>
</tr>
<tr>
<td style="font-weight: bold; font-family: Lucida Console;" valign="top">erase_digit(&nbsp;<span style="font-family: Comic Sans MS; font-style: italic;">r</span>,&nbsp;<span style="font-family: Comic Sans MS; font-style: italic;">c</span>
)</td>
<td align="undefined" valign="top">Erase&nbsp;the
puzzle cell at row&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">r</span>,
column&nbsp;<span style="font-family: Comic Sans MS; font-style: italic; font-weight: bold;">c</span>,
returning success or error status.</td>
</tr>
</tbody>
</table>
<h3 style="color: rgb(0, 187, 0);"><span style="font-family: Helvetica,Arial,sans-serif;">Puzzle
Module Internal (static) Functions</span></h3>
<p>The puzzle module also declares and defines a set of utility
functions to aid in implementing the interface. As these are internal
to the module, you are not required to use them - you can arugment or
replace them with other functions of your own design (replacement
requires <span style="font-style: italic; text-decoration: underline;">complete</span>
eradication of <span style="font-style: italic; text-decoration: underline;">all</span>
traces of the replaced functions).</p>
<p style="font-family: Helvetica,Arial,sans-serif;"><span style="font-weight: bold; color: rgb(204, 0, 0);">Note (if you use your own ideas):</span></p>
<ul>
<li>You are still responsible for providing <span style="font-style: italic; text-decoration: underline;">all</span>
the specified interface behavior for <span style="font-style: italic; text-decoration: underline;">each</span>
level of functionality, and</li>
<li>Your code must still adhere to high qualities of structure,
naming, documentaition, and partitioning. Long, convoluted, poorly
indented or inadequately documented code will cost you dearly in terms
of quality.</li>
</ul>
<h2 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 153, 0);">Tasks
&amp; Deliverables</h2>
<p>The project is organized as a sequence of six functionality levels.
Each level requires you to extend the work done at the previous level.
For each level 1 through 6 you will fill out the associated estimating,
tracking, and reflection activity outlined in the file <span style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">Track+Reflect.doc</span>.
15% of your project grade rides on your attention to the details of
estimating the time it will take you to complete the activity, track
that time and accurately record it when the level is done, and provide
thoughtful reflection on the work you did. Some levels are relatively
straightforward and require less in the way of reflection. Still, if
you have little in the way of thoughtful reflection for any of the
activities and the overall summary, expect to be docked heavily.</p><p>Similarly, 15% of your grade is based on the quality of the your implementation. Aspects considered include:</p><ul><li><span style="font-weight: bold;">Naming:</span>
Are variable, function and other names meaningful? Do they have a clear
relation to their role in the computation? Would a competent developer
be able to pick up this code and understand why you chose the names you
did?</li><li><span style="font-weight: bold;">Documentation:</span> Do
you use comments to simply repeat the code or to provide insight into
its context and intention? Are comments, clear, concise, and correct?
Are comments readable - do they avoid distracting grammatical and
spelling errors? Are the aligned with the code to make it obvious which
comments refer to which sections of code?</li><li><span style="font-weight: bold;">Structure</span>:
Are the bodies of functions organized into clear, coherent sets of
statements that clearly contribute to the function's goals? As
appropriate, are sections of code factored out into local functions of
their own, either to simplify the original function, to enhance
readability, or to adhere to DRY (Don't Repeat Yourself)?</li><li><span style="font-weight: bold;">Style</span>:
Does the layout of the code enhance its readability? Do you use
consistent indentation in line with examples done in class? Do you use
blank lines to separate distinct blocks of code? Do you use spaces to
enhance readability (or are expressions scrunched together, making it
difficult to distinguish variables from operators from constants)?</li></ul>
<h3><span style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Level 0 (Compiles &amp; Links)</span></h3><p>This
is a pseudo level, in that all your puzzle.c must do is compile and
link against the rest of the program, and your Track+Reflect.doc must
contain a reflection on whatever you did. As these conditions can be
met by simply submitting the puzzle.c skeleton in the zip file and
almost anything for thetracking and reflection, this is really a test of whether you can submit to myCourses. </p><h3 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Level 1 (Puzzle Module Initialization and Printing of an Empty Puzzle)</h3><p>Fill in the body of the <span style="font-weight: bold; color: rgb(51, 51, 255);">init_puzzle()</span> function and write the <span style="font-weight: bold; color: rgb(51, 51, 255);">print_puzzle()</span> function. Skeletons for two static methods related to printing are there for your completion and use: <span style="font-weight: bold; color: rgb(51, 51, 255);">print_dashes()</span> and <span style="font-weight: bold; color: rgb(51, 51, 255);">print_row(row)</span>. When your modifications compile and link, test them using make:</p><p style="margin-left: 40px; font-weight: bold; font-family: Helvetica,Arial,sans-serif;">make test_l1</p><h3 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Level 2 (Initialization, Configuration and Printing of a Real Puzzle)</h3><p>Fill in the body of the <span style="font-weight: bold; color: rgb(51, 51, 255);">configure(puzzle_file)</span> function, ignoring any error conditions for now. This requires you to</p><ul><li>Read three digit characters and a newline from the file whose handle is the argument (see the <small><span style="font-weight: bold; font-family: Helvetica,Arial,sans-serif;">Puzzle Configuration File Format</span><span style="font-family: Helvetica,Arial,sans-serif;"></span></small> section).</li><li>Convert each digit character to the number it represents,</li><li>Place the value in the puzzle cell designated by the row and column, and finally,</li><li>Mark the selected cell as fixed.</li></ul>When your
modifications compile and link, test them using make:<p style="margin-left: 40px; font-weight: bold; font-family: Helvetica,Arial,sans-serif;">make test_l2</p><h3 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Level 3 (Add and Erase Commands)</h3><p>Fill in the bodies of <span style="font-weight: bold; color: rgb(51, 51, 255);">add_digit(row, col, digit)</span> and <span style="font-weight: bold; color: rgb(51, 51, 255);">erase_digit(row, col)</span>, ignoring any error conditions for now.</p><p>When your modifications compile and link, test them using make:</p><p style="margin-left: 40px; font-weight: bold; font-family: Helvetica,Arial,sans-serif;">make test_l3</p><p style="font-weight: bold;"><span style="font-weight: normal;">This
runs three tests: one a simple test of adding, one a simple test of
erasing, and one which&nbsp;solves a real puzzle - the
last&nbsp;printout shows a completed puzzle.</span><br></p><h3 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Level 4 (Syntax and Simple Add/Erase Errors)</h3>Change the <span style="font-weight: bold; color: rgb(51, 51, 255);">configure</span> function:<ol><li>Discard everything after the three digit characters up to and including the next newline&nbsp;or <span style="font-weight: bold;">EOF</span>.</li><li>Check to ensure they are all digit characters in the range '1' through '9'; if any are not in range, print the message:<br>&nbsp; &nbsp; <span style="font-weight: bold;">Illegal format in configuration file at line <span style="font-style: italic;">N</span></span>, where <span style="font-weight: bold; font-style: italic;">N</span> is the line number, and call <span style="font-weight: bold; color: rgb(51, 51, 255);">exit(1)</span>.<br>You may find it useful to complete the skeleton helper function <span style="font-weight: bold; color: rgb(51, 51, 255);">in_range(value)</span>.</li><li>Ensure that the cell at the selected row and column is not already filled with a value; if it is, print the message:<br>&nbsp; &nbsp; <span style="font-weight: bold;">Illegal placement in configuration file at line <span style="font-style: italic;">N</span></span>, where, once again, <span style="font-weight: bold; font-style: italic;">N</span> is the line number, and call <span style="font-weight: bold; color: rgb(51, 51, 255);">exit(1)</span>.</li></ol><p>Change the <span style="font-weight: bold; color: rgb(51, 51, 255);">add_digit</span> function:</p><ol><li>If any of the three arguments is not in the range 1 .. 9, return <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_BADARGS</span> without changing the puzzle.&nbsp;You may find the&nbsp;helper function <span style="font-weight: bold; color: rgb(51, 51, 255);">in_range(value)</span> useful.</li><li>If the selected cell already has a value in it (i.e., it is non-zero), return <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_OCCUPIED</span> without changing the puzzle.</li></ol><p>Change the <span style="font-weight: bold; color: rgb(51, 51, 255);">erase_digit</span> function:</p><ol><li>If either of the two arguments is not in the range 1 .. 9, return <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_BADARGS</span> without changing the puzzle.You may find the&nbsp;helper function <span style="font-weight: bold; color: rgb(51, 51, 255);">in_range(value)</span> useful.</li><li>If the selected cell is already empty (i.e., its value is 0), return <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_OCCUPIED</span> without changing the puzzle.</li><li>If the selected cell is fixed (non-eraseable), return <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_FIXED</span> without changing the puzzle.</li></ol><p>When your modifications compile and link, test them using make:</p><p style="margin-left: 40px; font-weight: bold; font-family: Helvetica,Arial,sans-serif;">make test_l4</p><p style="font-weight: bold;"><span style="font-weight: normal;">This
runs a series of tests, the first few with different combinations of
bad configuration files, and a last one with a valid puzzle but bad (<span style="font-weight: bold;">a</span>)dd and (<span style="font-weight: bold;">e</span>)rase commands.</span></p><h3 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Level 5 (Row and Column Rule Violations)</h3>Change the <span style="font-weight: bold; color: rgb(51, 51, 255);">configure</span> function:<ol><li>Check
to ensure that the value being placed in the puzzle is not already in
the row or column specified. If it would be a duplicate, print the
message:<br>&nbsp; &nbsp; <span style="font-weight: bold;">Illegal placement in configuration file at line <span style="font-style: italic;">N</span></span>, where <span style="font-weight: bold; font-style: italic;">N</span> is the line number, and call <span style="font-weight: bold; color: rgb(51, 51, 255);">exit(1)</span>
- you may want to add this check onto the previous one that produces
this message. You may find it useful to complete the skeleton helper
functions <span style="font-weight: bold; color: rgb(51, 51, 255);">row_contains(row, digit)</span> and <span style="font-weight: bold; color: rgb(51, 51, 255);">col_contains(col, digit)</span>.</li></ol><p>Change the <span style="font-weight: bold; color: rgb(51, 51, 255);">add_digit</span> function:</p><ol><li>Check to ensure that the value being added in the puzzle is not already
in the row or column specified. If it would be a duplicate, return <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_ILLEGAL</span> without changing the puzzle.<br>You may find the helper functions&nbsp;<span style="font-weight: bold; color: rgb(51, 51, 255);">row_contains(row, digit)</span> and <span style="font-weight: bold; color: rgb(51, 51, 255);">col_contains(col, digit)</span> useful.</li></ol>When your modifications compile and link, test them using make:<p style="margin-left: 40px; font-weight: bold; font-family: Helvetica,Arial,sans-serif;">make test_l5</p><span style="font-weight: normal;">This runs a series of tests, the first few with different combinations of bad configuration files, </span><span style="font-weight: normal;">and a last one with a valid puzzle but </span><span style="font-weight: normal;">bad (<span style="font-weight: bold;">a</span>)dd commands.</span><h3 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 187, 0);">Level 6 (Region Rule Violations)</h3>Change the <span style="font-weight: bold; color: rgb(51, 51, 255);">configure</span> function:<ol><li>Check
to ensure that the value being placed in the puzzle is not already in
the region specified. If it would be a duplicate, print the message:<br>&nbsp; &nbsp; <span style="font-weight: bold;">Illegal placement in configuration file at line <span style="font-style: italic;">N</span></span>, where <span style="font-weight: bold; font-style: italic;">N</span> is the line number, and call <span style="font-weight: bold; color: rgb(51, 51, 255);">exit(1)</span>
- you may want to add this check onto the previous one that produces
this message. You may find it useful to complete the skeleton helper
function <span style="font-weight: bold; color: rgb(51, 51, 255);">region_contains(row, col, digit)</span>.</li></ol><p>Change the <span style="font-weight: bold; color: rgb(51, 51, 255);">add_digit</span> function:</p><ol><li>Check to ensure that the value being added in the puzzle is not already
in the region specified. If it would be a duplicate, return <span style="font-weight: bold; color: rgb(51, 51, 255);">OP_ILLEGAL</span> without changing the puzzle.<br>You may find the&nbsp;helper function <span style="font-weight: bold; color: rgb(51, 51, 255);">region_contains(row, col, digit)</span><span style="font-weight: bold; color: rgb(51, 51, 255);"></span> useful.</li></ol>When your modifications compile and link, test them using make:<p style="margin-left: 40px; font-weight: bold; font-family: Helvetica,Arial,sans-serif;">make test_l6</p><p style="font-weight: bold;"><span style="font-weight: normal;">This runs a series of tests, the first few with different combinations of bad configuration files, </span><span style="font-weight: normal;">and a last one with a valid puzzle but </span><span style="font-weight: normal;">bad (<span style="font-weight: bold;">a</span>)dd commands.</span><br></p><h2 style="font-family: Helvetica,Arial,sans-serif; color: rgb(0, 153, 0);">Assessment</h2>
<table style="margin-left: 30px; margin-right: 40px;" valign="top" border="1" cellpadding="3" cellspacing="1">
<tbody>
<tr>
<td align="left" valign="top">Level 0
(puzzle.c compiles and links)</td>
<td style="vertical-align: top; text-align: right;">10</td>
</tr>
<tr>
<td align="left" valign="top">Level 1
(initialize and print empty puzzle)</td>
<td style="vertical-align: top; text-align: right;">10</td>
</tr>
<tr>
<td align="left" valign="top">Level 2
(initialize, configure and print a real puzzle)</td>
<td style="vertical-align: top; text-align: right;">15</td>
</tr>
<tr>
<td align="left" valign="top">Level 3 (add,
erase and solve a real puzzle)</td>
<td style="vertical-align: top; text-align: right;">15</td>
</tr>
<tr>
<td align="left" valign="top">Level 4 (detect
bad syntax and simple add / erase errors)</td>
<td style="vertical-align: top; text-align: right;">5</td>
</tr>
<tr>
<td align="left" valign="top">Level 5 (detect
adding duplicate values in row or column)</td>
<td style="vertical-align: top; text-align: right;">5</td>
</tr>
<tr>
<td align="left" valign="top">Level 6 (detect
adding duplicate values in a region)</td>
<td style="vertical-align: top; text-align: right;">10</td>
</tr>
<tr>
<td align="left" valign="top">Estimation,
tracking, analysis and reflection</td>
<td style="vertical-align: top; text-align: right;">15</td>
</tr>
<tr>
<td align="left" valign="top">Implementation
quality</td>
<td style="vertical-align: top; text-align: right;">15</td>
</tr>
</tbody>
</table><h2 style="color: rgb(0, 153, 0);"><span style="font-family: Helvetica,Arial,sans-serif;">Submission</span></h2><p>As you complete the tasks for each level and your program passes the associated tests, submit the following two files:</p><p style="font-weight: bold; font-family: Helvetica,Arial,sans-serif; margin-left: 40px;">puzzle.c<br>Track+Reflect.doc</p><p>Submissions made by the deadline shown on the course schedule will be deposited in the <span style="font-style: italic;">Project-1</span> dropbox. Submissions may be deposited in the <span style="font-style: italic;">Project-1-late</span> dropbox up to one day late with a 15% penalty.</p><ul><li><big style="color: red;"><big><span style="font-weight: bold;">The two files must be named <span style="font-style: italic; text-decoration: underline;">exactly</span> as shown above.</span></big></big></li><li><big style="color: red;"><big><span style="font-weight: bold;"><span style="font-style: italic; text-decoration: underline;">No</span> variations of <span style="font-style: italic; text-decoration: underline;">any</span> type - file extensions and capitalization included - are acceptable.</span></big></big></li><li><big style="color: red;"><big><span style="font-weight: bold;">Check after each submission that the files were properly uploaded</span></big></big></li></ul><p>You may submit as many times as you like - we suggest at least once per level, with&nbsp;<span style="font-weight: bold;">Track+Reflect.doc</span>
incorporating the work up through that level. We will only evaluate the
last submission you make, and myCourses records everything you submit,
so there is no risk associated with making many submissions.</p><p><span style="font-weight: bold; color: red;">CAVEAT:</span>&nbsp;
We assume that you, as a matter of course, check eachsubmission to
ensure it was properly uploaded and recorded. Thus we will not be
swayed by statements like "I submitted it and don't know what happened."</p></body></html>